// Copyright (C) 2010 Razvan Constantin <razvan.constantin@rconst.net>
//
// This file is part of FileBow.
//
// FileBow is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// FileBow is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with FileBow.  If not, see <http://www.gnu.org/licenses/>.

// String utility methods.

#ifndef FILEBOW_COMMON_STRINGS_H__
#define FILEBOW_COMMON_STRINGS_H__

#include <string>
#include <vector>

/**
 * Splits a string into pieces delimited by delimiter.
 * @param s String to split.
 * @param delim pieces delimiter character.
 * @param parts Output parts.
 */
void Split(const std::string& s, char delim, std::vector<std::string>* parts);

/**
 * Split string variant.
 * @see Split(const std::string&, char)
 */
std::vector<std::string> Split(const std::string&s, char delim);

/**
 * Joins a list of strings.
 * @param parts Elements to join.
 * @param sep Separator for in between elements.
 */
std::string Join(const std::vector<std::string>& parts, const std::string& sep);

/**
 * Tests whether the string starts with the prefix.
 * An empty prefix doesn't match.
 * @return true if string s starts with prefix or false if the prefix is empty
 *  or is not found at the start of the string.
 */
bool StartsWith(const std::string& s, const std::string& prefix);

#endif // FILEBOW_COMMON_STRINGS_H__
